let receivedList = [
    {
        "id": "0",
        "qname": "关于水果的问卷调查",
        "qid": "0",
        "state": "交卷",
        "public": "公开",
        "anonymous": "记名",
        "answerer": '员工A',
        "start_time": "2020-04-01 10:00:00",
        "end_time": "2020-04-10 10:30:00",
        "answers": [
            {
                "qsid": '0',
                "qstype": '0',
                "qcontent": "您是否听说过XXX？",
                "selected_options": "仅听说过"
            },
            {
                "qsid": '1',
                "qstype": '1',
                "qcontent": "以下您喜欢的水果有哪些？",
                "selected_options": ["西瓜","桃子","榴莲"]
            },
            {
                "qsid": '2',
                "qstype": '2',
                "qcontent": "您对我们有什么建议？",
                "selected_options": '',
                "input": "这是一项很有意义的调查。"
            },
        ]
    },
    {
        "id": "1",
        "qname": "问卷五",
        "qid": "4",
        "state": "交卷",
        "public": "非公开",
        "anonymous": "匿名",
        "start_time": "2020-04-02 16:00:00",
        "end_time": "2020-04-05 16:30:00",
        "answers":[]
    },
    {
        "id": "2",
        "qname": "对于XX的意见收集",
        "qid": "1",
        "state": "交卷",
        "public": "公开",
        "anonymous": "记名",
        "answerer": '员工A',
        "start_time": "2020-04-02 11:00:00",
        "end_time": "2020-04-30 11:30:00",
        "answers":[]
    },
    {
        "id": "3",
        "qname": "关于水果的问卷调查",
        "qid": "0",
        "state": "交卷",
        "public": "公开",
        "anonymous": "记名",
        "answerer": '员工B',
        "start_time": "2020-04-01 10:00:00",
        "end_time": "2020-04-10 10:30:00",
        "answers":[
            {
                "qsid": '0',
                "qstype": '0',
                "qcontent": "您是否听说过XXX？",
                "selected_options": "从未听说过"
            },
            {
                "qsid": '1',
                "qstype": '1',
                "qcontent": "以下您喜欢的水果有哪些？",
                "selected_options": ["西瓜","桃子","芒果"]
            },
            {
                "qsid": '2',
                "qstype": '2',
                "qcontent": "您对我们有什么建议？",
                "selected_options": '',
                "input": "我认为水水水水水水。"
            },
        ]
    },
    {
        "id": "4",
        "qname": "关于水果的问卷调查",
        "qid": "0",
        "state": "交卷",
        "public": "公开",
        "anonymous": "记名",
        "answerer": '员工C',
        "start_time": "2020-04-01 10:00:00",
        "end_time": "2020-04-10 10:30:00",
        "answers": [
            {
                "qsid": '0',
                "qstype": '0',
                "qcontent": "您是否听说过XXX？",
                "selected_options": "听说过且了解"
            },
            {
                "qsid": '1',
                "qstype": '1',
                "qcontent": "以下您喜欢的水果有哪些？",
                "selected_options": ["桃子","榴莲"]
            },
            {
                "qsid": '2',
                "qstype": '2',
                "qcontent": "您对我们有什么建议？",
                "selected_options": '',
                "input": "建议建议水水水水水水。"
            },
        ]
    },
    {
        "id": "5",
        "qname": "问卷四",
        "qid": "3",
        "state": "未交卷",
        "public": "公开",
        "anonymous": "匿名",
        "start_time": "2020-04-06 11:00:00",
        "end_time": "2020-05-15 11:30:00",
        "answers":[]
    },
    {
        "id": "6",
        "qname": "问卷五",
        "qid": "4",
        "state": "交卷",
        "public": "非公开",
        "anonymous": "匿名",
        "start_time": "2020-04-02 16:00:00",
        "end_time": "2020-04-05 16:30:00",
        "answers":[]
    },
    {
        "id": "7",
        "qname": "对于XX的意见收集",
        "qid": "1",
        "state": "未交卷",
        "public": "公开",
        "anonymous": "记名",
        "answerer": '员工B',
        "start_time": "2020-04-02 11:00:00",
        "end_time": "2020-04-30 11:30:00",
        "answers":[]
    },
    {
        "id": "8",
        "qname": "问卷四",
        "qid": "3",
        "state": "交卷",
        "public": "公开",
        "anonymous": "匿名",
        "start_time": "2020-04-06 11:00:00",
        "end_time": "2020-05-15 11:30:00",
        "answers":[]
    },
    {
        "id": "9",
        "qname": "问卷三",
        "qid": "2",
        "state": "交卷",
        "public": "非公开",
        "anonymous": "记名",
        "answerer": '员工A',
        "start_time": "2020-04-05 11:00:00",
        "end_time": "2020-04-20 11:30:00",
        "answers":[]
    }
]


export default {
    'get|/getReceivedList': option => {
        return {
            status: 200,
            message: 'success',
            data: receivedList
        }
    },
    'get|/getAnswerNumber': option => {
        let answerNumberList = []
        receivedList.forEach(item => {
            let b = false
            answerNumberList.forEach(element => {
                if(item.qid==element.qid){
                    element.num++
                    element.answerList.push(item.answers)
                    b = true
                }
            })
            if(!b){
                answerNumberList.push({
                    qid:item.qid,
                    num:1,
                    answerList:[item.answers]
                })
            }
        })

        receivedList.forEach(item => {
        })
        return {
            status: 200,
            message: 'success',
            data: answerNumberList
        }
    },
    'post|/getDetailedStatistics': option => {
        const questionnairId = JSON.parse(option.body).params.questionnair_id
        console.log(questionnairId)
        let returnData = []
        receivedList.forEach(item => {
            if(item.qid===questionnairId){
                returnData.push(item)
            }
        })
        return {
            status: 200,
            message: 'success',
            data: returnData
        }
    },
}